#!/bin/bash
SERVER='http://localhost:8080/api'
BURRITO='burrito'
USERDIR='scripts/search/data/in/users'
OUTDIR='/tmp/searchusers'
rm -rf $OUTDIR
mkdir -p $OUTDIR

create () {
  pass=`cat $1 | jq .userName | tr -d \"`
  echo $pass
  resp=$(curl -s -H "Content-type:application/json" -X POST -d @$1 "$SERVER/builtin-users?password=$pass&key=$BURRITO")
  echo $resp | jq . > $OUTDIR/$1
}

cd $USERDIR
for i in `ls`; do
    create $i
done
